#pragma once
//SRM422DiV2_500
//SRM422DIV1_250
//2009/10/23 16:27:36
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class PrimeSoccer
{
public:
	double dp1[19][19];
	double dp2[19][19];
	bool prime[19];// = {false};
	double getProbability(int skillOfTeamA, int skillOfTeamB)
	{
		return solve(skillOfTeamA, skillOfTeamB);
	}
	double solve(double a, double b)
	{
		double ans = .0;
		memset(prime, false, sizeof(prime));
		prime[2] = true;
		prime[3] = true;
		prime[5] = true;
		prime[7] = true;
		prime[11] = true;
		prime[13] = true;
		prime[17] = true;

		memset(dp1, 0, sizeof(dp1));
		memset(dp2, 0, sizeof(dp2));

		dp1[0][0] = 1.0;
		dp2[0][0] = 1.0;

		a /= 100.0;
		b /= 100.0;

		for(int i=1; i<19; i++)
			for(int j=0; j<19; j++)
			{
				dp1[i][j] = dp1[i-1][j] * (1. - a);
				if(j>0)
					dp1[i][j] += dp1[i-1][j-1] * a;
				dp2[i][j] = dp2[i-1][j] * (1. - b);
				if(j>0)
					dp2[i][j] += dp2[i-1][j-1] * b;
			}
		for(int i=0; i<19; i++)
			for(int j=0; j<19; j++)
				if(prime[i] || prime[j])
					ans += dp1[18][i]*dp2[18][j];
		return ans;
	}
};
